package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 品牌mapper
 *
 * @author xxx
 */
public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 新增品牌和分类表中间表的数据
     *
     * @param id   品牌id
     * @param cids 分类id
     * @return int
     */
    int insertCategoryBrand(@Param("bid") Long id, @Param("ids") List<Long> cids);

    /**
     * 根据分类id查询品牌
     * @param categoryId
     * @return
     */
    @Select("SELECT b.id, b.name, b.letter, b.image " +
            "FROM tb_category_brand cb " +
            "INNER JOIN tb_brand b ON b.id = cb.brand_id " +
            "WHERE cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(@Param("cid") Long categoryId);
}
